package Builder;

public class Person {
    private String name;
    private int age;
    private String sex;

    private Person(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                '}';
    }

    public static class PersonBuilder {
        private String name;
        private int age;
        private String sex;

        public PersonBuilder setname(String name){
            this.name = name;
            return this;
        }

        public PersonBuilder setage(int age){
            this.age = age;
            return this;
        }

        public PersonBuilder setsex(String sex){
            this.sex = sex;
            return this;
        }

        public Person builder(){
            return new Person(name,age,sex);
        }
    }
}
